﻿@model List<CoffeeMobile.Models.ViewModels.FoodGroupModel>
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section Header{
    @Html.ActionLink("Home", "Index", "Home", null, new Dictionary<string, object> { { "data-icon", "home" }, { "class", "ui-btn-left" } })
    <h1>
        Food List</h1>
}
<ul data-role="listview" data-filter="true" data-filter-placeholder="Tìm nước uống và thức ăn ...">
    @foreach (FoodGroupModel item in Model)
    {
       
        <li data-role="list-divider">@item.Name</li>
        foreach (FoodModel subitem in item.FoodModels)
        {
            {
                Html.ViewContext.Writer.Write("<li><a href='#pu" + @subitem.ID + "' data-rel='popup' data-transition='slidedown'>");
                Html.ViewContext.Writer.Write("<img src=" + @Url.Content("../../Content/img/" + @subitem.Image) + " />");
                Html.ViewContext.Writer.Write("<h2>" + @subitem.Name + "</h2>");
                Html.ViewContext.Writer.Write("<p>" + @subitem.Description+ "</p>");
                Html.ViewContext.Writer.Write("</a></li>");
                Html.ViewContext.Writer.Write("<div data-role='popup' class='ui-corner-all' style='min-width:210px;min-height:100px;' id='pu" + @subitem.ID + "'>");
                Html.ViewContext.Writer.Write("<a href='#' data-rel='back' data-role='button' data-theme='a' data-icon='delete' data-iconpos='notext' class='ui-btn-right'>Close</a>");
                Html.ViewContext.Writer.Write("<div style='padding:10px;'>");
                Html.ViewContext.Writer.Write("<a href='/Foods/Details/?foodid=" + @subitem.ID + "' id='btnEdit' data-role='button' data-theme='b' data-icon='gear'>Chi tiết</a>");
                Html.ViewContext.Writer.Write("<a href='/Foods/Edit/?foodid=" + @subitem.ID + "' id='btnEdit' data-role='button' data-theme='b' data-icon='gear'>Chỉnh sửa</a>");
                Html.ViewContext.Writer.Write("<a href='/Foods/Delete/?foodid=" + @subitem.ID + "' onclick='' data-role='button' data-theme='b' data-icon='delete'>Xóa</a>");
                Html.ViewContext.Writer.Write("</div>");
                Html.ViewContext.Writer.Write("</div>");
            }
        }
    }
</ul>
@section footer{
    <div data-role="navbar" data-iconpos="top">
        <ul id="mylist">
            <li>@Html.ActionLink("Thêm mới", "Create", "Foods", new { }, new Dictionary<string, object> { })</li>
            <li>@Html.ActionLink("Làm mới", "Clear", "Tables", new { }, new Dictionary<string, object> { })</li>
        </ul>
    </div>
}
<div id="dialog">
</div>
@section scripts{
    <script type="text/javascript">
        function btnDelete_Click() {
            $("#dialog").dialog({
                dialogClass: "no-close",
                buttons: [{ text: "OK", click: function () { $(this).dialog("close"); } }]
            });
        }
    </script>
}
